const mysql = require('mysql');

const connection = mysql.createConnection({
    host: '110.42.189.230',
    port: '3306',
    user: 'vesitinDB',
    password: 'yds123',
    database: 'vesitindb'
});

connection.connect(err => {
    if (err) throw err;
    console.log('Successfully connected to the database.');
});

connection.on('error', err => {
    console.log('Database connection error:', err);
    if (err.code === 'PROTOCOL_CONNECTION_LOST') {
        console.log('Reconnecting...');
        connection.connect();
    } else {

    }
});


module.exports = connection;

// 使用connection进行数据库操作...